package tedu.spring.life;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * Spring bean 对象的生命周期
 */
@Repository
public class Life {
    private String meaning;

    public Life() {
        System.out.println("1:实例化阶段");
    }

    @Value("世界那么大，我想去看看")
    public void setMeaning(String meaning) {
        this.meaning = meaning;
        System.out.println("2:属性赋值");
    }

    @PostConstruct
    public void init() {
        System.out.println("3:生命周期初始化阶段");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("5:生命周期销毁阶段");
    }
}
